package huanfuan.demo.design;

import huanfuan.demo.design.store.ICommodity;
import huanfuan.demo.design.store.impl.CardCommodityService;
import huanfuan.demo.design.store.impl.CouponCommodityService;
import huanfuan.demo.design.store.impl.GoodsCommodityService;

/**
 * @Author huanfuan
 * @Date 2022/1/10 15:19
 * @Version 1.0
 */
public class StoreFactory {


    public ICommodity getCommodityService(Integer commodityType){
        if (null == commodityType) return null;
        if (1 == commodityType) return new CouponCommodityService();
        if (2 == commodityType) return new GoodsCommodityService();
        if (3 ==commodityType)  return new CardCommodityService();
        throw new RuntimeException("不存在的商品服务类型");
    }

}
